﻿from datetime import datetime
from os.path import dirname, join, abspath, exists
from os import getcwd, makedirs
from sys import stderr, __stderr__
from objects import goods

__dir__ = getcwd()
path_error = join(__dir__, "goods.log")
filesdir = join(__dir__, "files")
if not exists(filesdir): makedirs(filesdir)
xlsx_file = join(filesdir, "goods.xls")
stderr = open(path_error, 'a')
stderr.write("\n\n--------------------------***-----------------------------\nExport has begun...\nLocal Date and Time: "+str(datetime.now())+"\n--------------------------***-----------------------------\n\n")

list=[]
temp=input("Введите код номенклатуры 1С77:\n")
while temp!='':
	list+=[temp]
	temp=input()

print("Данные будут выгружены в files\\goods.xls\n")
o=goods()
o.write(xlsx_file, o.extract(list))


stderr.write("\nNo errors logged.\n\n\n--------------------------***-----------------------------\nExport has finished...\nLocal Date and Time: "+str(datetime.now())+"\n--------------------------***-----------------------------\n\n\n\n\n")
stderr.close()
stderr = __stderr__